#include <iostream>
#include <string>
#include <vector>

size_t split(const std::string &str, const std::string &sep, std::vector<std::string> &result)
{
    // news...music.#pop
    size_t pos = 0, index = 0;
    while (index < str.size())
    {
        pos = str.find(sep, index);   // 从str的index位置开始找
        if (pos == std::string::npos) // 找不到分隔符，即为最后的一段
        {
            result.push_back(str.substr(index));
            return result.size();
        }
        // 找到分割符
        if (pos != index) // 如果位置一致，表示均为分隔符，不添加进result
        {
            result.push_back(str.substr(index, pos - index));
        }
        index = pos + sep.size();
    }
    return result.size();
}

int main()
{
    std::vector<std::string> vec;
    int num = split("news...music.#pop", ".", vec);
    for (auto &e : vec)
    {
        std::cout << e << std::endl;
    }
}